runtime! debian.vim

syntax on
syntax enable

if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

set nocompatible
highlight Comment ctermfg=magenta guifg=magenta

set nu
syntax on
syntax enable
set cursorline cursorcolumn

colorscheme solarized
set background=dark

set showmatch
set ignorecase
set smartcase
set hidden

set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab

set showmode

set nobackup
set noswapfile
set nowb

set history=700
filetype plugin on
filetype indent on

set autoread
set autowrite

set ruler
set hid
set cmdheight=2
set incsearch
set hlsearch

set magic
set lazyredraw
set mat=2

set noerrorbells
set novisualbell
set t_vb=
set tm=500

set enc=utf-8
set tenc=utf-8
set fencs=utf-8,ucs-bom,utf-16,big5,gb2312,bg18030,gbk,cp936,chinese,latin-1
set fenc=utf-8
set ffs=unix

source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim

set so=3
set wildmenu
set wildignore=*.o,*~,*.pyc

set smarttab

set lbr
set tw=500

set autoindent
set smartindent
set wrap

set t_Co=256


set backspace=eol,start,indent
set whichwrap+=<,>,h,l

set guifont=Consolas:h9:cANSI


let mapleader=","
let g:mapleader=","

nmap <leader>w :w!<cr>

vnoremap <silent> * :call VisualSelection("f")<CR>
vnoremap <silent> # :call VisualSelection("b")<CR>

map j gj
map k gk

map <space> /
map <c-space> ?

map <silent> <leader><cr> :noh<cr>

map <C-j> <C-W>j
map <C-k> <C-W>k
map <C-h> <C-W>h
map <C-l> <C-W>l

map <leader>bd :Bclose<cr>

map <leader>ba :1,1000 bd!<cr>

map <leader>tn :tabnew<cr>
map <leader>to :tabonly<cr>
map <leader>tc :tabclose<cr>
map <leader>tm :tabmove

map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
map <leader>cd :cd %:p:h<cr>:pwd<cr>
try
    set switchbuf=useopen,usetab,newtab
    set stal=2
catch
endtry

set laststatus=2
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]

map 0 ^

nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
nmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
nmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z

if has("mac") || has("macunix")
    nmap <D-j> <M-j>
    nmap <D-k> <M-k>
    vmap <D-j> <M-j>
    vmap <D-k> <M-k>
endif

func! DeleteTrailingWS()
      exe "normal mz"
      %s/\s\+$//ge
      exe "normal `z"
endfunc

autocmd BufWrite *.py :call DeleteTrailingWS()
autocmd BufWrite *.coffee :call DeleteTrailingWS()

vnoremap <silent> gv :call VisualSelection('gv')<CR>
map <leader>g :vimgrep // **/*.<left><left><left><left><left><left><left>
map <leader><space> :vimgrep // <C-R>%<C-A><right><right><right><right><right><right><right><right><right>

vnoremap <silent> <leader>r :call VisualSelection('replace')<CR>

map <leader>cc :botright cope<cr>
map <leader>co ggVGy:tabnew<cr>:set syntax=qf<cr>pgg
map <leader>n :cn<cr>
map <leader>p :cp<cr>

map <leader>ss :setlocal spell!<cr>
 
map <leader>sn ]s
map <leader>sp [s
map <leader>sa zg
map <leader>s? z=
noremap <Leader>m mmHmt:%s/<C-V><cr>//ge<cr>'tzt'm

if has("autocmd")
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
endif
